package com.example.chapter0;

import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.chapter0.utils.Utils;

public class ViewActivity2 extends AppCompatActivity {

    @Override
    @SuppressLint("MissingInflatedId")
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_view2);
         TextView textView = findViewById(R.id.tv_code);
        //获取布局参数
        ViewGroup.LayoutParams params = textView.getLayoutParams();
        //默认px单位
        params.width = Utils.dipToPx(this,300);
        textView.setLayoutParams(params);
    }
}